//
//  MyControllerButton.cpp
//  CanYouDoIt
//
//  Created by hoangtx on 7/15/13.
//
//

#include "MyControllerButton.h"

bool MyControllerButton::init(){
    MySpriteButton::init();
    return true;
}

MyControllerButton* MyControllerButton::create(const char *fileName, const char *spriteOnTopFileName, double mX, double mY, double mWidth, double mHeight){
    MyControllerButton* button = MyControllerButton::create();
    button->setPosition(ccp(mX,mY));
    button->buttonSize = CCSizeMake(mWidth, mHeight);
    button->sprite = CCSprite::create(fileName);
    button->sprite->setAnchorPoint(ccp(0,0));
    button->sprite->setScaleX(mWidth/button->sprite->getContentSize().width);
    button->sprite->setScaleY(mHeight/button->sprite->getContentSize().height);
    button->sprite->setPosition(ccp(0,0));
    button->sprite->setColor(button->normalColor);
    button->addChild(button->sprite);
    
    button->spriteOnTop = CCSprite::create(spriteOnTopFileName);
    button->spriteOnTop->setAnchorPoint(ccp(0.5,0.5));
    button->spriteOnTop->setScaleX(mWidth*0.7/button->spriteOnTop->getContentSize().width);
    button->spriteOnTop->setScaleY(mHeight*0.7/button->spriteOnTop->getContentSize().height);
    button->spriteOnTop->setPosition(ccp(mWidth/2,mHeight/2));
    button->addChild(button->spriteOnTop);
    return button;
}

void MyControllerButton::goToDisabledMode(){
    sprite->setColor(spriteOnTop->getColor());
}

